package com.shenjinzheng.controller;

import com.shenjinzheng.common.Result;
import com.shenjinzheng.dto.AdminLoginDTO;
import com.shenjinzheng.service.AdminService;
import com.shenjinzheng.vo.AdminLoginVO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("")
public class AuthController {

    @Resource
    private AdminService adminService;

    @PostMapping("/login")
    public Result<AdminLoginVO> login(@RequestBody AdminLoginDTO adminLoginDTO){
        log.info("{}",adminLoginDTO);
        String token = adminService.login(adminLoginDTO);
        AdminLoginVO adminLoginVO = new AdminLoginVO();
        adminLoginVO.setToken(token);
        return Result.success(adminLoginVO);
    }
}
